﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.IO;

namespace System.Web.Mvc.Html
{

    /// <summary>
    /// Clase que permite construír helpers HTML
    /// </summary>
    public static class HtmlHelperFabrica
    {
        /// <summary>
        /// Construye HtmlHelper a partir ViewContext, un IViewDataContainer, y un TextWriter que reemplaze el del ViewContext
        /// </summary>
        /// <param name="viewContext"></param>
        /// <param name="viewDataContainer"></param>
        /// <param name="stringWriter"></param>
        /// <returns></returns>
        public static HtmlHelper crearDeViewContextViewDataContainerYTextWriter(ViewContext viewContext, IViewDataContainer viewDataContainer, TextWriter textWriter)
        {
            var viewCtx = new ViewContext(new ControllerContext(viewContext.RequestContext, viewContext.Controller),
                   viewContext.View, viewContext.ViewData, viewContext.TempData, textWriter);
            return new HtmlHelper(viewCtx, viewDataContainer);
        }
    }
}